<!DOCTYPE html>
<html>
    <head>
        <title>Pick-up Game</title>
        <link rel="stylesheet" href="style.css" type="text/css" />
        <script type="text/javascript" src="index.js"></script>
        <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    </head>

    <body>

        <?php include_once('menu.php') ?>
        <?php
	      // connect to database
		$conn_str = 'host=dbsrv1.cdf.toronto.edu dbname=csc309g23 user=csc309g23 password=ipheid5h';
		$conn = pg_connect($conn_str);
		
		$query_top_players = 'SELECT username,firstname,lastname,playrating FROM members WHERE playrating IS NOT NULL ORDER BY playrating DESC LIMIT 5';
		$result_top_players = pg_query($conn,$query_top_players);

		$query_top_orgs = 'SELECT username,firstname,lastname,orgrating FROM members WHERE orgrating IS NOT NULL ORDER BY orgrating DESC LIMIT 5';
		$result_top_orgs = pg_query($conn,$query_top_orgs);
		    
	?>

	<div class="container">
	
        <h2>Welcome</h2>
        <hr></hr>
        Welcomg to our pickup game website. Join us to socialize within sports circles, meet new people and have fun playing pickups games in your neighbourhood.
        
        
        <h2>Top Players</h2>
        <hr></hr>
                            <table class="displayTable">
			    
                                <tr><td>username</td><td>Name</td><td>Skill Rating</td></tr>
			    <?php while($top_players=pg_fetch_row($result_top_players)){

				?>
                                <tr><td><?php echo $top_players[0] ?> </td><td><?php echo $top_players[1]." ".$top_players[2] ?></td><td><?php echo $top_players[3] ?></td></tr>
			     <?php } ?>
                            </table>
                            
                            
        <h2>Top Organizers</h2>
        <hr></hr>
                            <table class="displayTable">
                                <tr><td>username</td><td>Name</td><td>Organizer Rating</td></tr>
                                <?php while($top_orgs=pg_fetch_row($result_top_orgs)){

				?>
                                <tr><td><?php echo $top_orgs[0] ?> </td><td><?php echo $top_orgs[1]." ".$top_orgs[2] ?></td><td><?php echo $top_orgs[3] ?></td></tr>
			     <?php } ?>
            </table>
        </fieldset>
    </div>
    </body>

</html>
